from http.server import BaseHTTPRequestHandler,HTTPServer
class RequestHandler(BaseHTTPRequestHandler):
    Page = '''\
    <html>
        <body>
        <p>hello,python_web!</p>
        </body>
        </html>
    '''
    def do_GET(self):
        page = self.create_page()
        self.send_content(page)

    def create_page(self):
        values = {
            'date_time': self.date_time_string(),
            'client_host': self.client_address[0],
            'client_port': self.client_address[1],
            'command': self.command,
            'path': self.path
        }
        page = self.Page.format(**values)
        return page
    def send_content(self,page):
        self.send_response(200)
        self.send_header("Content_Type", "text/html")
        self.send_header("Content_Length", str(len(page)))
        self.end_headers( )
        self.wfile.write(self.Page.encode("utf-8"))

if __name__ == '__main__':
    serverAddress = ('',8080)
    server = HTTPServer(serverAddress,RequestHandler)
    server.serve_forever()